//package com.yyt.send.shedule;
//
//import com.alibaba.fastjson.JSONObject;
//import com.yyt.send.domain.SendMessage;
//import com.yyt.send.repository.SendMessageRepository;
//import com.yyt.send.util.HttpUtils;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//
//import javax.annotation.Resource;
//import java.util.Date;
//
///**
// * @author yeyangtao created at 19:21 2020/9/10
// */
//@Configuration
//@EnableScheduling
//public class Send {
//    @Resource
//    private SendMessageRepository repository;
//    public static final String URL1 = "https://user.ifeng.com/api/v1/sendsms?platform=w&systemid=1";
//    public static final String PHONE = "17779035392";
//
//    @Scheduled(cron = "0 0/2 * * * ?")
//    public void sendMessage() {
//        JSONObject object1 = new JSONObject();
//        object1.put("mobile", PHONE);
//        object1.put("smsform", 1);
//        System.out.println(new Date()+":开始执行");
//        try {
//            String res = HttpUtils.sendPostDataByJson(URL1, object1.toJSONString());
//            System.out.println(res);
//            SendMessage message = new SendMessage(res, true);
//            repository.saveAndFlush(message);
//        } catch (Exception e) {
//            System.out.println(e.getMessage());
//            SendMessage message = new SendMessage(e.getMessage(), false);
//            repository.saveAndFlush(message);
//        }
//    }
//}
